﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="website_admin_knowlegebase_kbarticleslist" Codefile="kbarticleslist.aspx.cs" %>

<%@ Register Src="../../admin/_root/_controls/ctlNavBar.ascx" TagName="ctlNavBar"
    TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>

    <script src="../_common/scripts/jquery-1.4.1.min.js" type="text/javascript"></script>

    <script type="text/javascript" language="javascript" src="../_common/scripts/util.js"></script>

    <link href="../../_common/styles/form_2_0.css" rel="stylesheet" type="text/css" />
    <link href="../../_common/flexigrid/flexigrid_blue.css" rel="stylesheet" type="text/css" />

    <script language="javascript" type="text/javascript">
        var pre_scrollLeft=0;
        $(document).ready(setup);
        function setup()
        {
            LoadingData();
        }
        /// 自动校对左右滚动条
        $(window).resize(function(){
            if(document.getElementById("scrool_left1"))
            {
	            if(pre_scrollLeft != document.getElementById("scrool_left1").scrollLeft){
                    pre_scrollLeft=document.getElementById("scrool_left1").scrollLeft; 
                    $(".hDivBox").css("margin-left", -pre_scrollLeft);
                }
            }
        });

        function ItemSelected(_obj)
        {
            var _itemsId = document.getElementById("txtItemsId");

            if (_obj.checked) {
                if (_itemsId.value.indexOf("'" + _obj.oid + "'") == -1) {
                    _itemsId.value += "'" + _obj.oid + "',";
                } 
                $("#"+_obj.id).parent().parent().parent().addClass("trSelected");
            }
            else {
                _itemsId.value = _itemsId.value.replace("'" + _obj.oid + "',", "");
                $("#"+_obj.id).parent().parent().parent().removeClass("trSelected"); 
            }
        }
        function SelectedAllItems()
        {
            var _itemsId = document.getElementById("txtItemsId");

            $("input[name='cbxItems']").each(function() {
                if (!$(this).attr("disabled")) { 
                    _objectid = $(this).attr("oid");

                    if (!$(this).attr("checked")) {
                        $(this).attr("checked", true);

                        /// 加入队列
                        if (_itemsId.value.indexOf("'" + _objectid + "'") == -1) {
                            _itemsId.value += "'" + _objectid + "',";
                        } 
                        $(this).parent().parent().parent().addClass("trSelected");
                    }
                    else {
                        $(this).attr("checked", false);
                        _itemsId.value = _itemsId.value.replace("'" + _objectid + "',", "");
                        $(this).parent().parent().parent().removeClass("trSelected"); 
                    }
                }
            });
        }
        function DeleteItems(_obj) { 
            if (confirm("Are you sure you want to delete the selected record?"))
            {
                var _itemsId = document.getElementById("txtItemsId").value;
                if(_itemsId != "")
                {
                    _itemsId += "|";
                    _itemsId = _itemsId.replace(",|", "").replace("'", "").replace("'", "");
                    
                    $.ajax({
                        async: false,
                        type: "POST",
                        url: "kbarticleslist.aspx",
                        data: {
                            otype: "deleteitems",
                            itemsid: _itemsId
                        },
                        success: function(data, textStatus) { 
                            if (data == "succeeded") { 
                                alert("Successfully removed!");
                                $("#txtItemsId").val("");
                                LoadingData();
                            }
                            else {
                                alert(data);
                            }
                        }
                    });
                }
                else
                    alert("Please select a record to be deleted!");
            }
        } 
        var pageIndex = "1";
        var pageSize = 10;
        /// 分页
        function pagination(index)
        {
            pageIndex = index;
            LoadingData();
        }
        /// 查询
        function Search()
        {
            pageIndex = 1;
            LoadingData();
        }
        /// 每页显示记录数设定
        function ChangePagesize(rp)
        {
            pageSize = rp.value;
            LoadingData();
        }
        function LoadingData() {
            $.ajax({
                async: true,
                type: "POST",
                url: "kbarticleslist.aspx",
                data: {
                    index: pageIndex,
                    pagesize: pageSize,
                    otype: "loadingdata",
                    title: $("#txtTitle").val(),
                    category: $("#selCategoryList").val()
                },
                beforeSend: function() {
                    $("#divItemsList").html("<div class=\"tDiv\"></div>" + $("#divTreeLoading").html() + "<div class=\"pDiv\"></div>");
                },
                success: function(data, textStatus) { 
                    $("#divItemsList").html("");
                    $("#divItemsList").html(data);
                }
            });
        }    
        function OpenDia(otype, objectid) {
            var groupid = getUrlParam("groupid");
            switch (otype) {
                case "add":
                    switch (getUrlParam("c_number")) {
                        case "0001200001":
                            openStdWin(prependOrgName("/website_admin/knowlegebase/courseeditor.aspx?otype=add&c_number=" + $("#selCategoryList").val()), buildWinName(), 920, 660);
                            break;
                        case "0001200002":
                            openStdWin(prependOrgName("/website_admin/knowlegebase/modeleditor.aspx?otype=add&c_number=" + $("#selCategoryList").val()), buildWinName(), 920, 660);
                            break;
                        case "0001200003":
                            openStdWin(prependOrgName("/website_admin/knowlegebase/kbarticleeditor.aspx?otype=add&c_number=" + $("#selCategoryList").val()), buildWinName(), 920, 660);
                            break;
                        case "0001200004":
                            openStdWin(prependOrgName("/website_admin/knowlegebase/partnewseditor.aspx?otype=add&c_number=" + $("#selCategoryList").val()), buildWinName(), 920, 660);
                            break;
                        case "0000900002":
                            openStdWin(prependOrgName("/website_admin/knowlegebase/kbarticleeditor.aspx?otype=add&c_number=" + $("#selCategoryList").val()), buildWinName(), 920, 660);
                            break;
                        case "0000900003":
                            openStdWin(prependOrgName("/website_admin/knowlegebase/kbarticleeditor.aspx?otype=add&c_number=" + $("#selCategoryList").val()), buildWinName(), 920, 660);
                            break;
                        case "0000900004":
                            openStdWin(prependOrgName("/website_admin/knowlegebase/modeleditor.aspx?otype=add&c_number=" + $("#selCategoryList").val()), buildWinName(), 920, 660);
                            break;
                        case "00008":
                            openStdWin(prependOrgName("/website_admin/knowlegebase/fileeditor.aspx?otype=add&c_number=" + $("#selCategoryList").val()), buildWinName(), 920, 660);
                            break;
                        default:
                            openStdWin(prependOrgName("/website_admin/knowlegebase/kbarticleeditor.aspx?otype=add&c_number=" + $("#selCategoryList").val()), buildWinName(), 920, 660); 
                            break;
                    }
                    break; 
                case "modify":
                    switch (getUrlParam("c_number"))
                    {
                        case "0001200001":
                            openStdWin(prependOrgName("/website_admin/knowlegebase/courseeditor.aspx?otype=modify&articleid=" + objectid + "&c_number=" + $("#selCategoryList").val()), buildWinName(), 920, 660);
                            break;
                        case "0001200002":
                            openStdWin(prependOrgName("/website_admin/knowlegebase/modeleditor.aspx?otype=modify&articleid=" + objectid + "&c_number=" + $("#selCategoryList").val()), buildWinName(), 920, 660);
                            break;
                        case "0001200003":
                            openStdWin(prependOrgName("/website_admin/knowlegebase/kbarticleeditor.aspx?otype=modify&articleid=" + objectid + "&c_number=" + $("#selCategoryList").val()), buildWinName(), 920, 660);
                            break;
                        case "0001200004":
                            openStdWin(prependOrgName("/website_admin/knowlegebase/partnewseditor.aspx?otype=modify&articleid=" + objectid + "&c_number=" + $("#selCategoryList").val()), buildWinName(), 920, 660);
                            break;
                        case "0000900002":
                            openStdWin(prependOrgName("/website_admin/knowlegebase/kbarticleeditor.aspx?otype=modify&articleid=" + objectid + "&c_number=" + $("#selCategoryList").val()), buildWinName(), 920, 660);
                            break;
                        case "0000900003":
                            openStdWin(prependOrgName("/website_admin/knowlegebase/kbarticleeditor.aspx?otype=modify&articleid=" + objectid + "&c_number=" + $("#selCategoryList").val()), buildWinName(), 920, 660);
                            break;
                        case "0000900004":
                            openStdWin(prependOrgName("/website_admin/knowlegebase/modeleditor.aspx?otype=modify&articleid=" + objectid + "&c_number=" + $("#selCategoryList").val()), buildWinName(), 920, 660);
                            break;
                        case "00008":
                            openStdWin(prependOrgName("/website_admin/knowlegebase/fileeditor.aspx?otype=modify&articleid=" + objectid + "&c_number=" + $("#selCategoryList").val()), buildWinName(), 920, 660);
                            break;
                        default:
                            openStdWin(prependOrgName("/website_admin/knowlegebase/kbarticleeditor.aspx?otype=modify&articleid=" + objectid + "&c_number=" + $("#selCategoryList").val()), buildWinName(), 920, 660); 
                            break;
                    }
                    break; 
            }
        }  
    </script>

</head>
<body scrool="no" style="margin: 0px; padding: 0px;">
    <div id="divTreeLoading" style="display: none;">
        <div class="bDiv" style="height: 320px;">
            <div style="background-color: #FFFFFF; table-layout: fixed; width: auto; height: 100%;
                text-align: center; margin-top: 30px;">
                <img border="0" src="../_imgs/admin/progress.gif" />
                <span style="line-height: 42px;">Loading ... </span>
            </div>
        </div>
    </div>
    <form id="aspnetForm" runat="server">
    <input name="txtItemsId" type="hidden" id="txtItemsId" />
    <div class="divAreas">
        <div class="boxTopBar_1">
            <div class="navBar">
                <uc1:ctlNavBar ID="ctlNavBar1" runat="server" />
            </div>
        </div>
                <table cellpadding="0" cellspacing="0" class="stdTable" style="width: 100%;">
            <tbody>
                <tr>
                    <td valign="top" style="padding: 8px 5px 0px;">
                        <table class="stdTable" cellpadding="2" cellspacing="2">
                            <colgroup>
                                <col style="padding-left: 2px; text-align: right; width: 60px;" />
                                <col style="width: 160px;" />
                                <col style="padding-right: 2px; text-align: right; width: 80px;" />
                                <col style="width: 200px;" /> 
                                <col />
                            </colgroup>
                            <tr>
                                <td>
                                    标题：
                                </td>
                                <td>
                                    <input type="text" id="txtTitle" name="txtTitle" class="textBox"  style=" width: 150px;"/>
                                </td>
                                <td style="text-align: right;">
                                    类别：
                                </td>
                                <td>
                                    <select id="selCategoryList" name="selCategoryList" runat="server" class="SelectBox"> 
                                    </select>
                                </td>
                                <td>
                                    <input id="Button1" class="btn_s" value="搜索" type="button" onclick="Search();" />
                                </td> 
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr style="height: 100%;">
                    <td valign="top" style="padding: 5px 5px 0px;">
                        <div class="flexigrid" id="divItemsList">
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    </form>
</body>
</html>
